import 'dart:async';

import 'package:flutter/material.dart';

export 'package:get/get.dart';
export 'package:lottie/lottie.dart';
export 'fun_util.dart';
export 'date_format/date_util.dart';
export 'gallery/gallery.dart';
export 'gallery/model.dart';
export 'video/index.dart';
export 'img_util.dart';
export 'config.dart';
export 'parm.dart';
export 'ex/list.dart';
export 'ex/num.dart';
export '../component/component.dart';
export 'screen_adapter/screen_adapter.dart';

bool isZeroList(List? a) {
  if (a == null) {
    return true;
  }

  if (a.isEmpty) {
    return true;
  }
  return false;
}

bool isNilStr(String? str) {
  if (str == null) {
    return true;
  }
  if (str == '') {
    return true;
  }

  if (str == 'null') {
    return true;
  }

  return false;
}

bool isZero(dynamic x) {
  if (x == null) {
    return true;
  }
  if (x is String) {
    int x0 = int.tryParse(x) ?? 0;
    if (x0 == 0) {
      return true;
    }
    return false;
  }
  if (x is int) {
    return x == 0;
  }
  return true;
}

num numVal(dynamic x) {
  if (x == null) {
    return 0;
  }
  if (x is String) {
    return num.tryParse(x) ?? 0;
  }
  if (x is num) {
    return x;
  }
  return 0;
}

String getDurationStr(dynamic duration) {
  if (duration == null) {
    return '0';
  }
  int duration0 = 0;
  if (duration is String) {
    duration0 = int.tryParse(duration) ?? 0;
  }
  if (duration is int) {
    duration0 = duration.toInt();
  }

  if (duration0 <= 0) {
    return '0';
  }

  var minutes = (duration0 / 60).truncate();
  var second = duration0 - minutes * 60;

  if (minutes <= 0) {
    return '${second}s';
  }
  if (minutes > 0 && minutes < 60) {
    return '$minutes:$second';
  }
  if (minutes > 90) {
    var hour = (minutes / 60).truncate();
    var minute = minutes - hour * 60;
    return '$hour:$minute:$second';
  }
  return '0';
}
